package cn.edu.zafu.bigdata.llc;

import java.util.List;
import java.util.Comparator;

public class GenericMaxFinder {

    // 泛型方法 findMax
    public static <T> T findMax(List<T> list, Comparator<T> comparator) {
        if (list == null || list.isEmpty()) {
            throw new IllegalArgumentException("List must not be null or empty");
        }
        T max = list.get(0);
        for (T item : list) {
            if (comparator.compare(item, max) > 0) {
                max = item;
            }
        }
        return max;
    }
}
